(SST) ShlWAPI.pas Version 1.08

Developer Reference
(SST)ShlWAPI PathSearchAndQualify Function
Creates a fully qualifed path from a relative path.
Scope
Global (i.e. this function can be called/accessed from code in any unit that includes/uses (SST)ShlWAPI.pas).
Syntax
function PathSearchAndQualify(pszPath : LPCSTR; pszBuf : LPSTR; cchBuf : UINT) : BOOL;
Parameters
pszPath [in] Pointer to null terminated string that is the path to convert into a fully qualified path.
pszBuf [out] Buffer into which the function should write the null-terminated, output string.
cchBuf [in] The size, in number of characters of the output buffer.
Return Values
The function returns TRUE if the specifed, input path (pszPath) and/or the path written to the output buffer are fully qualified paths.
Remarks
This function is similar in functionality to the Delphi SDK function ExpandFileName.
If at all, the function only performs a very rudimentary syntax check.
Example
PROCEDURE TForm4.TestShlWAPIPathSearchAndQualify(Sender : TObject); VAR pathtotest : STRING; VAR qualifiedpathbuf : ARRAY[0.. MAX_PATH] OF CHAR; VAR bufsize : UINT; VAR apiretval : BOOL; VAR newinfoline : STRING; BEGIN pathtotest := ''; FillChar(qualifiedpathbuf, Length(qualifiedpathbuf), #0); bufsize := 0; apiretval := FALSE; newinfoline := ''; pathtotest := 'C:\Windows\System32'; bufsize := Length(qualifiedpathbuf); newinfoline := 'PathSearchAndQualify called with ' + pathtotest; Memo1.Lines.Add(newinfoline); apiretval := PathSearchAndQualify(PChar(pathtotest), qualifiedpathbuf, bufsize); IF apiretval THEN newinfoline := 'TRUE ' + qualifiedpathbuf ELSE newinfoline := 'FALSE'; Memo1.Lines.Add(newinfoline); pathtotest := 'C:\Hello\World'; bufsize := Length(qualifiedpathbuf); newinfoline := 'PathSearchAndQualify called with ' + pathtotest; Memo1.Lines.Add(newinfoline); apiretval := PathSearchAndQualify(PChar(pathtotest), qualifiedpathbuf, bufsize); IF apiretval THEN newinfoline := 'TRUE ' + qualifiedpathbuf ELSE newinfoline := 'FALSE'; Memo1.Lines.Add(newinfoline); pathtotest := '\\SAMPLESERVER\DemoShare\DummyFolder\DummySubfolder'; bufsize := Length(qualifiedpathbuf); newinfoline := 'PathSearchAndQualify called with ' + pathtotest; Memo1.Lines.Add(newinfoline); apiretval := PathSearchAndQualify(PChar(pathtotest), qualifiedpathbuf, bufsize); IF apiretval THEN newinfoline := 'TRUE ' + qualifiedpathbuf ELSE newinfoline := 'FALSE'; Memo1.Lines.Add(newinfoline); pathtotest := 'X:\DummyFolder\DummySubfolder\HelloWorld.c'; bufsize := Length(qualifiedpathbuf); newinfoline := 'PathSearchAndQualify called with ' + pathtotest; Memo1.Lines.Add(newinfoline); apiretval := PathSearchAndQualify(PChar(pathtotest), qualifiedpathbuf, bufsize); IF apiretval THEN newinfoline := 'TRUE ' + qualifiedpathbuf ELSE newinfoline := 'FALSE'; Memo1.Lines.Add(newinfoline); pathtotest := '..\DummyFolder\DummySubfolder\HelloWorld.c'; bufsize := Length(qualifiedpathbuf); newinfoline := 'PathSearchAndQualify called with ' + pathtotest; Memo1.Lines.Add(newinfoline); apiretval := PathSearchAndQualify(PChar(pathtotest), qualifiedpathbuf, bufsize); IF apiretval THEN newinfoline := 'TRUE ' + qualifiedpathbuf ELSE newinfoline := 'FALSE'; Memo1.Lines.Add(newinfoline); pathtotest := '..\Y:\\DummyFolder/DummySubfolder/HelloWorld.c'; bufsize := Length(qualifiedpathbuf); newinfoline := 'PathSearchAndQualify called with ' + pathtotest; Memo1.Lines.Add(newinfoline); apiretval := PathSearchAndQualify(PChar(pathtotest), qualifiedpathbuf, bufsize); IF apiretval THEN newinfoline := 'TRUE ' + qualifiedpathbuf ELSE newinfoline := 'FALSE'; Memo1.Lines.Add(newinfoline); Memo1.Lines.Add(''); END;
The above example will produce an output similar or identical to that below.
PathSearchAndQualify called with C:\Windows\System32 TRUE C:\Windows\System32 PathSearchAndQualify called with C:\Hello\World TRUE C:\Hello\World PathSearchAndQualify called with \\SAMPLESERVER\DemoShare\DummyFolder\DummySubfolder TRUE \\SAMPLESERVER\DemoShare\DummyFolder\DummySubfolder PathSearchAndQualify called with X:\DummyFolder\DummySubfolder\HelloWorld.c TRUE X:\DummyFolder\DummySubfolder\HelloWorld.c PathSearchAndQualify called with ..\DummyFolder\DummySubfolder\HelloWorld.c TRUE D:\Projects\SST\SSTShlWAPI\DummyFolder\DummySubfolder\HelloWorld.c PathSearchAndQualify called with ..\Y:\\DummyFolder/DummySubfolder/HelloWorld.c TRUE S:\Projects\SST\SSTShlWAPI\Y:\DummyFolder\DummySubfolder\HelloWorld.c
Requirements
Unit: Declared and imported in (SST)ShlWAPI.pas
Library: (SST)ShlWAPI.dcu/(SST)ShlWAPI.obj
Unicode: Implemented as ANSI (PathSearchAndQualify and PathSearchAndQualifyA) and Unicode (PathSearchAndQualifyW) functions.
Min. ShlWAPI.dll version according to MS SDK doc.: 4.71
Min. ShlWAPI.dll version based on SST research: 4.71
Min. OS version(s) according to Microsoft SDK doc.: Windows 2000, Windows NT 4.0 with Internet Explorer 4.0, Windows 98, Windows 95 with Internet Explorer 4.0
Min. OS version(s) according to SST research.: Windows NT 4.0 with IE 4.0, Windows 95 with IE 4.0, Windows 98, Windows 2000 and later
See Also
 
 
Windows APIs: PathSearchAndQualify, PathIsRelative, PathIsUNC, PathIsUNCServer, PathIsUNCServerShare, PathIsURL.


Document/Contents version 1.00
Page/URI last updated on 07.12.2023
 
Copyright © Stoelzel Software Technologie (SST) 2010 - 2017
Suggestions and comments mail to:
webmaster@stoelzelsoftwaretech.com